package no.sachmuld.methodcombination.examples.annotation.combo;

import no.sachmuld.methodcombination.api.reflection.component.SimpleMethodCombination;
import no.sachmuld.methodcombination.api.reflection.component.MethodCombination;
import no.sachmuld.methodcombination.impl.annotation.MethodCombinationInitializer;
import no.sachmuld.methodcombination.impl.annotation.MethodCombinationImplementation;

import java.lang.annotation.*;
import java.util.Map;

/**
 *
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@MethodCombinationImplementation(
        value = no.sachmuld.methodcombination.examples.reflection.combo.SimpleCrosscutting.class,
        initializer = SimpleCrosscutting.Initializer.class,
        nested = SimpleMethodCombination.class)
public @interface SimpleCrosscutting {

    public class Initializer implements MethodCombinationInitializer {
        @Override
        public void initialize(MethodCombination methodCombination, Annotation annotation, Map<Class<? extends MethodCombination>, MethodCombination> dependencyMap) {

            no.sachmuld.methodcombination.examples.reflection.combo.SimpleCrosscutting simpleCrosscutting = (no.sachmuld.methodcombination.examples.reflection.combo.SimpleCrosscutting) methodCombination;
            SimpleMethodCombination simpleMethodCombination = (SimpleMethodCombination) dependencyMap.get(SimpleMethodCombination.class);

            simpleCrosscutting.setSimpleMethodCombination(simpleMethodCombination);

        }
    }

}
